package com.dengqi.mymodule.activity.unittest;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.dengqi.mymodule.BaseActivity;
import com.dengqi.mymodule.R;

/**
 * https://www.jianshu.com/p/925191464389
 */
public class UnitTestActivity extends BaseActivity {

    private EditText etNum1, etNum2;
    private TextView tvResult;
    private Button btnSubmit;
    private Calculator calculator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unittest);

        calculator = new Calculator();
        etNum1 = findViewById(R.id.et_num1);
        etNum2 = findViewById(R.id.et_num2);
        tvResult = findViewById(R.id.tv_result);
        btnSubmit = findViewById(R.id.btn_submit);
        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                double result = calculator.sum(Double.parseDouble(etNum1.getText().toString()), Double.parseDouble(etNum2.getText().toString()));
                tvResult.setText(result + "");
            }
        });
    }


}
